Skip to content

feat(parser): support MySQL 8.0.19+ INSERT row alias syntax#33

Open
paultyng wants to merge 2 commits intosqlc-dev:mainfrom
paultyng:2026-04-30-1726-update-to-latest-mysql-syntax-in-auth-token
Open

feat(parser): support MySQL 8.0.19+ INSERT row alias syntax#33
paultyng wants to merge 2 commits intosqlc-dev:mainfrom
paultyng:2026-04-30-1726-update-to-latest-mysql-syntax-in-auth-token

Conversation

@paultyng
Copy link
Copy Markdown

@paultyng paultyng commented May 1, 2026

Replays pingcap/tidb#67920 into marino. Partial fix for #22.

  • Adds RowAlias / ColumnAliases to ast.InsertStmt and InsertRowAliasOpt grammar on INSERT ... VALUES and INSERT ... SET.
  • Rejects the alias on REPLACE (shared InsertValues rule).
  • Parser-only. Planner/executor alias resolution is out of scope.

Not covered (follow-up): the INSERT ... SELECT ... AS new form from #22. Adding it requires extending the four Select-branched alternatives of InsertValues and may introduce grammar ambiguity with SELECT's own AS table alias — left for a separate PR.

paultyng and others added 2 commits May 1, 2026 09:13
Add parsing support for the `AS row_alias[(col_alias, ...)]` clause
in INSERT ... VALUES and INSERT ... SET statements, as introduced in
MySQL 8.0.19 (WL #6312) and required since VALUES() was deprecated
in MySQL 8.0.20.

Examples:
  INSERT INTO t VALUES (1,2) AS new ON DUPLICATE KEY UPDATE b = new.b;
  INSERT INTO t VALUES (1,2) AS new(m,n) ON DUPLICATE KEY UPDATE b = m;
  INSERT INTO t SET a=1,b=2 AS new ON DUPLICATE KEY UPDATE b = new.a;

This is a parser-only change; planner/executor support for resolving
the alias references is not included. The INSERT ... SELECT form of
the row alias is not yet supported.

Replays pingcap/tidb#67920. Refs sqlc-dev#22.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
REPLACE does not support the AS row_alias syntax in MySQL.
Since ReplaceIntoStmt reuses InsertValues, add a check to
reject any row alias parsed via that shared grammar rule.

Replays pingcap/tidb#67920. Refs sqlc-dev#22.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@paultyng
Copy link
Copy Markdown
Author

paultyng commented May 4, 2026

@kyleconroy wasn't sure where things stood with accepting PRs here while you are forking this. I'm working in a MySQL codebase so was trying to get the newer upsert functionality in to it via sqlc. I had opened this PR on tidb, but figured I should also bring it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant